package com.example.common.provider3.controller;

import com.example.common.provider3.service.Provider3Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.PostConstruct;

/**
 * @author wangjinlong
 * @date 2022/2/15 11:37
 */
@RestController
@RequestMapping("api/common/provider")
public class Provider3Controller {

    @Autowired
    private ApplicationContext applicationContext;

    @Autowired
    private Provider3Service provider3Service;

    @GetMapping("get")
    public String get(){
        String s = provider3Service.get();
        String json = "{\"name\":\"provider-3\",\"age\":100}";
        return s + ", " + json;
    }

    @PostConstruct
    public void test(){
        String[] names = applicationContext.getBeanDefinitionNames();
        for (String name : names) {
            System.out.println(name);
        }
    }
}
